package cn.hackcloud.mutithread.mutilthread.producer;

public class P {
	private Object lock;

	public P(Object lock) {
		this.lock = lock;

	}

	public void setValue() {
		try {
			synchronized (lock) {
				while (!ValueObject.value.equals("")) {
					lock.wait();
					System.out.println("生产者"+Thread.currentThread().getName()+"WAITING");
				}
				System.out.println("生产者"+Thread.currentThread().getName()+"RUNNABLE");
				String value = System.currentTimeMillis() + "_" + System.nanoTime();
				ValueObject.value = value;
				lock.notifyAll();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
